package com.springcloud.tools.utils;

import com.mongodb.DB;
import com.mongodb.MongoClient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;



@Component
public class MongoUtil {
  @Autowired private MongoClient mongoClient;

  public Boolean flag = true;

  /**
   * 创建DB
   *
   * @param dbName
   * @return
   */
  public DB getDB(String dbName) {
    if (dbName != null && !"".equals(dbName)) {
      @SuppressWarnings("deprecation")
      DB db = mongoClient.getDB(dbName);
      return db;
    }
    return null;
  }
}
